import { setLocalData, getLocalData } from "happy-utils/storage";

/**
 * 设置本地存储的值
 * @param {string} key
 * @param {string, obj} value
 */
function set(key, value) {

    if (typeof value === 'object') value = JSON.stringify(value);

    setLocalData('admin' + key, value);

    return true;
}

/**
 * 获取本地存储的值
 * @param {string} key
 * @param {boole} parse
 */
function get(key, parse) {

    let get = getLocalData('admin' + key);

    if (parse) get = JSON.parse(get);

    return get;
}

/**
 * 删除本地存储的值
 * @param {string} key
 */
function del(key) {
    localStorage.removeItem('admin' + key)
}

export default {
    set,
    get,
    del
};